import 'dart:convert';
import 'dart:typed_data';

import 'package:json_annotation/json_annotation.dart';
import 'package:my_flutter_test/models/utils.dart';

part 'user.g.dart';

@JsonSerializable(explicitToJson: true)
class User {
  String name; // 用户名作为主键
  String password;
  String token;
  @JsonKey(toJson:bytes2base64,fromJson: base2bytes)
  Uint8List img; // 图片通过json发送需要base64编码

  User(this.name, this.password, this.token, this.img);

  factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);

  Map<String, dynamic> toJson() => _$UserToJson(this);
}

